import {createRouter, createWebHistory} from "vue-router";
import Home from '@/Pages/Home.vue'
import About from '@/Pages/About.vue'
import News from '@/Pages/News.vue'
import Detail from '@/Pages/Detail.vue'

const router = createRouter({
    history: createWebHistory(),
    routes: [
        {
            name: 'shouye',
            path: '/home',
            component: Home
        },
        {
            name: 'xinwen',
            path: '/news',
            component: News,
            children: [
                {
                    name: 'xiangqing',
                    path: 'detail',// 可传可不传加?
                    component: Detail,
                    // 第一种写法, 将路由收到的所有params参数作为props传给组件
                    // props: true
                    // 第二种写法, 可以自己决定将什么传给props
                    props(route) {
                        return route.query
                    }
                }
            ]
        },
        {
            name: 'guanyu',
            path: '/about',
            component: About
        }
    ]
})

export default router